

$(document).ready(function(){

    /*-------------------------------------------------方法---------------------------------------------------*/

    //点击提交解锁目录密码
    $('.submit_unlock').on('click',function(e){
        $(this).val('正在提交...');
        $(this).attr('disabled',true);
        var pwd_input = $(this).parent('div').prev('div').find('input').val();
        var dirID = $(this).attr('data-dirid');
        var pID = $(this).attr('data-pid');
        var activeImgIndex = mySwiper.activeIndex;
        if(pwd_input==""){
            alert('目录解锁密码不能为空！');
            $(this).val('提交解锁...');
            $(this).attr('disabled',false);
        }else{
            $.ajax({
                type: "POST",
                url: mw_site_url+"/ashow/getPicInfosByDir",
                data:"pwd_input="+pwd_input+"&dirID="+dirID+"&activeIndex="+activeImgIndex+"&pID="+pID,
                dataType:"json",
                async:true,
                success: function(data){
                    switch(data){
                        case -1:
                            $(e.target).val('提交解锁');
                            $(e.target).attr('disabled',false);
                            alert('参数缺失，请刷新页面！');
                            break;
                        case -2:
                            $(e.target).val('提交解锁');
                            $(e.target).attr('disabled',false);
                            alert('密码错误！');
                            break;
                        default :
                            var pic_server_url = $('#pic_server_url').val();
                            for(var i=0;i<data.length;i++){
                                var img_obj = $("#"+data[i].picID);
                                img_obj.attr('data-lazysrc',pic_server_url+data[i].picUrl).show().siblings('.lock_mask').remove();
                                img_obj.remove('data-locklv');
                            }
                            SetImgSize(data[0]['activeIndex'],true,"");//渲染第一张图片
                            SetImgSize((data[0]['activeIndex']+1),true,""); //渲染第二张图片
                            $(".swiper-slide img:eq("+(data[0]['activeIndex'])+")").attr("src",function(){return $(this).attr("data-lazysrc")});
                            $(".swiper-slide img:eq("+(data[0]['activeIndex']+1)+")").attr("src",function(){return $(this).attr("data-lazysrc")});
                            alert('解锁成功！');
                            break;
                    }

                }
            });
        }
    });

    /*-------------------------------------------------方法---------------------------------------------------*/

}); //document.ready(end)
